vt-d: use 32-bit Destination ID when Interrupt Remapping with EIM is
authorKeir Fraser <keir.fraser@citrix.com>
Mon, 7 Sep 2009 07:46:03 +0000 (08:46 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Mon, 7 Sep 2009 07:46:03 +0000 (08:46 +0100)
commit5c53154b6190af523ec097dbb76c41685052dddd
tree8c1fccceda1bec3eb81f75400c5b6beab784a809
parentcda2f6c76132090176f4b88c84917861c21bd21c
vt-d: use 32-bit Destination ID when Interrupt Remapping with EIM is
enabled

When x2APIC and Interrupt Remapping(IR) with EIM are enabled, we
should use 32-bit Destination ID for IOAPIC and MSI.

We implemented the IR support in xen by hooking the functions like
io_apic_write(),io_apic_modify(), write_msi_message(), and as a
result, in the hook functions in intremap.c, we can only see the 8-bit
dest id rather the 32-bit id, so we can't set IR table Entry that
requires a 32-bit dest id.

To solve the issue throughly, we need find every place in io_apic.c
and msi.c that could write ioapic RTE and and device's msi message and
explicitly handle the 32-bit dest id carefully (namely, when genapic
is x2apic, cpu_mask_to_apic could return a 32-bit value); and we have
to change the iommu_ops->{.update_ire_from_apic, .update_ire_from_msi}
interfaces. We may have to write an over-1000-LOC patch for this.

Instead, we could use a workround:
1) for ioapic, in the struct IO_APIC_route_entry, we could use a new
"dest32" to refer to the dest field;
2) for msi, in the struct msi_msg, we could add a new "u32 dest".
And in intremap.c, if x2apic_enabled, we use the new names to refer to
the dest fields.

We can improve this in future.

Signed-off-by: Dexuan Cui <dexuan.cui@intel.com>
xen/arch/x86/io_apic.c
xen/arch/x86/msi.c
xen/drivers/passthrough/vtd/intremap.c
xen/include/asm-x86/io_apic.h
xen/include/asm-x86/msi.h